# Contributor: Galen Abell <galen@galenabell.com>
# Maintainer: Galen Abell <galen@galenabell.com>
pkgname=k9s
_pkgname=github.com/derailed/k9s
pkgver=0.30.6
pkgrel=0
pkgdesc="Kubernetes TUI"
url="https://k9scli.io"
# riscv64 FTBS
arch="all !x86 !armhf !riscv64" # tests fail
license="Apache-2.0"
makedepends="go"
subpackages="
	$pkgname-bash-completion
	$pkgname-zsh-completion
	$pkgname-fish-completion
	"
options="net chmod-clean"
source="$pkgname-$pkgver.tar.gz::https://github.com/derailed/k9s/archive/v$pkgver.tar.gz"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	local ldflags="
	-X $_pkgname/cmd.version=$pkgver
	-X $_pkgname/cmd.commit=AlpineLinux
	-X $_pkgname/cmd.date=$(date +%FT%T%Z)
	"
	go build -ldflags "$ldflags" -tags netgo -o execs/$pkgname

	./execs/k9s completion bash >k9s.bash
	./execs/k9s completion zsh >k9s.zsh
	./execs/k9s completion fish >k9s.fish
}

check() {
	go test ./...
}

package() {
	install -Dm755 execs/$pkgname "$pkgdir"/usr/bin/$pkgname

	install -Dm644 k9s.bash \
		"$pkgdir"/usr/share/bash-completion/completions/k9s
	install -Dm644 k9s.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_k9s
	install -Dm644 k9s.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/k9s.fish
}

sha512sums="
ef972ee5d4cd9bcd34b25134d15a17119af179c7db93f2a919dd2644bcbc6b40a0958112e78efc905fc409a2a0017b1aa735fc4937b0e726a9d1d8d3262e0a73  k9s-0.30.6.tar.gz
"
